/* ==================================================================
* Copyright (c) 2024/11/15 SCNU LiuJunJie z-ken
* All rights reserved.
* fileName:	Tree.h
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the xxx Group. and
* its contributors.
* 4. Neither the name of the Group nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Author,GROUP AND CONTRIBUTORS
* ===================================================================
* Author: LiuJunJie z-ken.
*/

//
// Created by zken on 2024/11/6.
//

#ifndef PROJECTLIZE_TREE_H
#define PROJECTLIZE_TREE_H


#include <iostream>

using namespace std;

#include <vector>
#include <queue>
// 语法分析树节点
class LalrTreeNode {
public:
    int id; // 维护的下标，对应treeNodes的下标
    string value;       // 该节点存放的字符串值
    vector<int> childs; // 该节点的孩子
};

// 分析树封装类，包含一个分析学术的根和已经添加的所有的分析树节点treeNodes
class Tree {
public:
    // 所有treeNode（数组树）- 根节点的位置不明确
    vector<LalrTreeNode> treeNodes;
    int rootId = -1;

    // 添加树节点
    int addNode(string value, vector<int> childs = vector<int>());
    // 深度搜索
    void showTreeNodes();
private:
    // showTreeNodes的辅助函数
    void showTreeNodesSupport(int rootId, int depth);
};


#endif //PROJECTLIZE_TREE_H
